[IRGenSIL] resolve objc_direct methods to precondition thunk if the flag is enabled#89234
Draft
DataCorrupted wants to merge 1 commit into
Draft
[IRGenSIL] resolve objc_direct methods to precondition thunk if the flag is enabled#89234DataCorrupted wants to merge 1 commit into
DataCorrupted wants to merge 1 commit into
Conversation
Contributor
Author
|
Targeting |
Contributor
Author
|
@swift-ci Please test |
Contributor
Author
|
@rjmccall The CI is using outdated toolchain and complaining "Libc++ only supports AppleClang 26.4 and later", and my local build would also fail because swift
It's my first time sending PR to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Swift has no notion of the ObjC flag
-fobjc-direct-precondition-thunkwe introduced in llvm/llvm-project#170618. This means when callingobjc_directmethods from swift, it will dispatch to the true implementation-[Class method]Dwithout the precondition check. This is incorrect.In this PR we patch that up. When
-fobjc-direct-precondition-thunkis enabled (queried from clang importergetClangCGM().getCodeGenOpts()), we lowerFunctionRefInstby askingclang::CodeGen::getObjCDirectMethodCalleewhich function (thunk or true impl) would be the best callee.A test is added to validate that we call correct thunk methods instead of true impl now.
An alternative approach is to do this query during
irgen::getObjCDirectMethodCallee, a later time when we have lost access to the originalObjCMethodDeclunless we add it toFunctionPointer- a change I believe breaks the LLVM-level only abstraction, and would be too disruptive. Would open to comments if that sounds like a better idea.